package com.tanguy.user.ui.me.activity

import cn.sinata.xldutils_kotlin.activity.WebViewActivity
import cn.sinata.xldutils_kotlin.callPhone
import cn.sinata.xldutils_kotlin.utils.getVersionName
import com.tanguy.user.App.Companion.app
import com.tanguy.user.Const
import com.tanguy.user.R
import com.tanguy.user.base.ImmersionTitleActivity
import com.tanguy.user.custom.TwoTextLinearView
import com.tanguy.user.ui.window.MessageWindow
import com.tanguy.user.utlis.extend.click
import com.tanguy.user.utlis.extend.showPopupWindow
import org.jetbrains.anko.find
import org.jetbrains.anko.startActivity

/**
 * Created by dab on 2017/10/9 0009 17:14
 * 更多页面
 */
class MoreActivity : ImmersionTitleActivity() {
    override fun setContentViewRes(): Int = R.layout.activity_more
    override fun initView() {
        super.initView()
        title = "更多"
        find<TwoTextLinearView>(R.id.ttv_service).rightText = app.user.servicephone
        click(R.id.ttv_safety) { startActivity<SafetyActivity>() }
        click(R.id.ttv_feedback) { startActivity<FeedbackActivity>() }
        click(R.id.ttv_about_we) { startActivity<WebViewActivity>("url" to Const.AppText.ABOUT_US, "title" to "关于我们")  }
        click(R.id.ttv_protocol) { startActivity<WebViewActivity>("url" to Const.AppText.PLATFORM_AGREEMENT, "title" to "平台协议") }
        click(R.id.ttv_service) { callPhone(app.user.servicephone)
           }
        click(R.id.tv_exit) {
            showPopupWindow(MessageWindow(this, "确认退出登录?"){
                if (it) {
                    app.logOut()
                    finish()
                }
            })
        }
        find<TwoTextLinearView>(R.id.ttv_versions).rightText = getVersionName()
    }
}